<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> 
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
com.jxtti.model.User userInfo = com.jxtti.utils.AuthUtil.getUserInfo(request);
String orgId=null;
if(userInfo.getDistrictId()==null || userInfo.getDistrictId().equals("0")){ //非超管
	orgId=userInfo.getOrgId().toString();
}
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=9" />
		<meta http-equiv="pragma" content="no-cache" />
		<title>新增文章</title>
		<%@ include file="../../../common/Admin-list.jsp"%>		
		<link rel="stylesheet" type="text/css" href="<%=basePath %>Themes/default/css/jquery.datetimepicker.css"/>    
		<script type="text/javascript" src="<%=basePath %>Scripts/jquery/jquery.datetimepicker.js"></script>
		
		<script type="text/javascript" src="<%=bpath %>Scripts/jquery/jquery.colorpicker.js"></script> 	
		
		<!-- 配置文件 -->
	    <script type="text/javascript" src="<%=path %>/Scripts/UEditor/ueditor.config.js"></script>
	    <!-- 编辑器源码文件 -->
	    <script type="text/javascript" src="<%=path %>/Scripts/UEditor/ueditor.all.js"></script>		
		  
		<script type="text/javascript" src="<%=bpath %>Scripts/jquery/jquery.form.js"></script> 		 
		 
		<script type="text/javascript">			
		$(function(){
			
			if(<%=orgId %>!=null){ //是否管理员
				$(".yincan").css('display','none');						
			}
			
			 $("#clicks").numeral();   //职能输入数字
			
			var subUrl="../ArticleList/save.json";
			if('${data.type}'!=null&&'${data.type}'=="add"){ //新增模块
				$("#lblTitle").html('新增文章');
				$('#menuSort').css('display','none');
			}else if('${data.type}'!=null&&'${data.type}'=="leftAdd"){//左侧 树状结构新增
				$("#lblTitle").html('新增文章');
				$('#menuSort').css('display','none');
				$("#categoryID").val('${data.categoryID}');		
				$("#categoryName").val('${data.categoryName}');					
			}else if('${data.type}'!=null&&'${data.type}'=="edit"){ //编辑模块				
				$("#lblTitle").html('编辑文章');
				$('#menuSort').css('display','none');	
				if('${data.articleList.issue}'=="0"){
					$("#issue").attr("checked",false);
				}				
				if('${data.articleList.isHomePic}'=="1"){
					$("#isHomePic").attr("checked",true);
				}				
				if('${data.articleList.isRecommend}'=="1"){
					$("#isRecommend").attr("checked",true);
				}				
				$("#articleSite").val('${data.articleList.articleSite}');				
				$("#id").val('${data.articleList.id}');			
				$("#title").val('${data.articleList.title}');	
				$("#subTitle").val('${data.articleList.subTitle}');	
				$("#title").css("color",'${data.articleList.titleColor}');
			    $("#titleColor").val('${data.articleList.titleColor}');
				$("#categoryID").val('${data.articleList.categoryID}');		
				$("#categoryName").val('${data.articleList.categoryName}');	
				$("#sortID").val('${data.articleList.sortID}');				
				
				$("#clicks").val('${data.articleList.clicks}');	
				$("#modifyDate").val('<fmt:formatDate pattern="yyyy-MM-dd HH:mm:ss"  value="${data.articleList.modifyDate}"  type="both" />');					
				subUrl="../ArticleList/update.json";
			}
			
			/*
				//标题颜色选择
				$("#cp4").colorpicker({
				    fillcolor:true,
				   // event:'mouseover',
				    success:function(o,color){
				        $("#title").css("color",color);
				        $("#titleColor").val(color);
				    }
				});
				$("#colorpanel").css("z-index",999);
			
			*/
			
			//保存
			$("#lnbSave").click(function(){								
				$("#addForm").ajaxSubmit({
					url:subUrl,
					type:"POST",
					beforeSubmit:checkForm,
					contentType:"application/x-www-form-urlencoded;charset=UTF-8",
					error:function(){},
					success:function(data){
						if(data.success==true){
							showTip("保存成功，返回列表页面！","succeed");	
							var win = artDialog.open.origin;//来源页面
							win.art.dialog({id: 'editDialog'}).close();
							//win.refresh();
						}else{
							//showTip("操作失败","warning");  
							art.dialog.alert('保存失败，请确认填写正确！');
						}
					}
				});
			});
			
			
		});
			
		function checkForm(){
			var flag=$('#addForm').form('validate');			
			return flag;
		}
				
		//消息提示  
		function showTip(mess,icon) {  
		    art.dialog({  
		        id : 'Tip',  
		        title : '消息',  
		        fixed : true,  
		        lock : true,  
		        opacity: 0.2,  
		        content : mess,  
		        icon : icon,  
		        time : 1  
		    });  
		    setTimeout('originReload()', 1000);  
		}  
		
		//重载来源页面  
		function originReload(){  
		   // var win = art.dialog.open.origin;	
		   // win.location.reload();  
		}		
		
		function getCategory(){  //选择图标
			art.dialog.open('../ArticleCategory/getCategoryInterface.htm',{
				title: '选择文章类目',
				lock:true,
			  	width:483,
			    height:514,
			    left:'10%',
			    top:'0%'
			});
      	}			
		</script>
		
</head>
<body>
<!---->
<div>
	<div id="tab">
        <ul>
            <li class="Current">
            	<a href="#" onfocus="this.blur()">
            		<span id="lblTitle" >  新增文章  </span>
            	</a>
            </li>
        </ul>
    </div>  
    <div id="menu">
        <ul>
            <li>
            	<a id="lnbSave">
            		<span><img src="<%=basePath %>pages/Admin/Images/Icon/save.gif" alt="Save" />保存</span>
            	</a>
            </li>
            <li style="color:red;margin-left:40%;font-size:16px;">上网信息不涉密，涉密信息不上网</li>
        </ul>
    </div>   
    
    <div id="middle"> 
    <form action="../ArticleList/save.json" id="addForm" name="addForm" method="post" >   
    <div class="editor">
        <table class="eTable">
            <tr class="eTr">
                <td class="name">         
                	 <label id="Label21" >网站显示</label>                    	  
                </td>
                <td>	
                	 <input id="issue" type="checkbox" name="issue" checked="checked" value="1"  style="vertical-align:middle;"/>
                	 <label for="issue">网站显示</label>
                	 &nbsp;&nbsp;&nbsp;&nbsp;
                	
                	 <input class="yincan" id="isHomePic" type="checkbox" name="isHomePic"  value="1" style="vertical-align:middle;"/>
                	 <label class="yincan" for="isHomePic">首页图片新闻</label>
                	 &nbsp;&nbsp;&nbsp;&nbsp;
                	 <input class="yincan" id="isRecommend" type="checkbox" name="isRecommend" value="1" style="vertical-align:middle;"/>
                	 <label class="yincan" for="issue">列表置顶</label>   
                	              	 
				</td>
            </tr>
        	   <tr class="eTr">
                <td class="name">
                   <label>文章目标平台：</label>	
                </td>
                <td>
                    <select id="articleSite" class="datatype"  name="articleSite">
						<option value="0" selected="selected">&nbsp;&nbsp;外网发布</option>							
						<option  value="1">&nbsp;&nbsp;内网发布&nbsp;&nbsp;</option>	
						<option  value="2">&nbsp;&nbsp;内网&外网发布</option>	
					</select>
					
					&nbsp;&nbsp;
					<strong>编辑时间：</strong>
					<input type="text" value="" name="modifyDate" id="modifyDate" class="inputdate" />	
					&nbsp;&nbsp;
					<strong>点击数：</strong>
					 <input id="clicks" name="clicks" value="0" size="5"></input>（请输入数字！）					
                </td>
            </tr> 
            <tr class="eTr">
                <td class="name">
                    <label id="LabelName" >文章标题</label>
                    <font color="red">*</font> 
                </td>
                <td>
                    <!-- <img src="<%=basePath %>Themes/default/images/colorpicker.png" id="cp4" style="cursor:pointer"/>-->
                    <input id="title" name="title" required="true" class="easyui-validatebox validatebox-text input"></input>
                    <input id="titleColor" name="titleColor" type="hidden"></input>
                     
                    <input id="id" name="id" type="hidden"></input>
                   	<input id="status" name="status"  type="hidden" value="2"></input>     
                    <input id="is_contribute" name="is_contribute"  type="hidden" value="0"></input>
                </td>
            </tr>        
            <tr class="eTr">
                <td class="name">
                    <label id="LabelName" >副标题</label>                    
                </td>
                <td>
                     <input id="subTitle" name="subTitle" class="easyui-validatebox validatebox-text input"></input>
                </td>
            </tr> 
            <tr class="eTr">
                <td class="name">
                    <label id="Label4">所属类目</label>
                	<font color="red">*</font>    
                </td>
                <td>
                	<input id="categoryName" name="categoryName" required="true" class="easyui-validatebox validatebox-text input" onclick="getCategory();"></input>   
                    <input id="categoryID" name="categoryID" type="hidden"></input>                    
                </td>
            </tr>
            <tr class="eTr" id="menuSort">
                <td class="name">
                    <label id="Label5" >文章排序</label></td>
                <td>
                    <input id="sortID" name="sortID" class="input" value="0"></input>
                </td>
            </tr>
            <!-- 百度编辑器  -->            
            <tr class="eTr">                
                <td colspan="2">
                	<!-- 加载编辑器的容器 -->
				    <script id="container" name="contents" type="text/plain" style="width:100%;height:240px;">
        				
    				</script>
                </td>
            </tr>
            
            
        </table>
        
    </div>
    </form> 
    </div>
    
    <!-- 实例化编辑器 -->
    <script type="text/javascript">
	    $('#modifyDate').datetimepicker({		
			maxDate : 0 ,  //'new Date()'
			format:'Y-m-d H:i',
			lang:'ch',
			// timepicker:false
		});
    
        var ue = UE.getEditor('container',{        	
        	autoClearinitialContent:true, //清除初始内容      
        	autoHeightEnabled: false,//是否自动长高，默认true
        	autoFloatEnabled:false, //是否保持toolbar的位置不动，默认true        	
        	topOffset :70        	//浮动时工具栏距离浏览器顶部的高度，用于某些具有固定头部的页面
        });        
              
       ue.ready(function() {
		    ue.setContent('${data.articleList.contents}');
		});		
    </script>
    
</div>
</body>
</html>